import java.util.Scanner;

//太高兴了 一次就做出来4.29
public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int num = sc.nextInt();
            if(num < 0) return ;
            System.out.println(counter(num));
        }
    }
    
    public static int counter(int num){
        int count = 0;  //完美数个数
        for(int i = 1; i < num; i++){
            int sum = 0;
            for(int j = 1; j < i; j++){
                if(i % j == 0){
                    sum += j;
                }
            }
            if(sum == i) count++; //判断该数的真因数和是否与该数相等，相等则count++
        }
        return count;
    }
}